/********************************************************************
	TABAL ENGINE - 2012/11/13
	author:		Marc Cuscullola
	
	purpose:	Defines the vertex buffer and index buffer to be rendered
*********************************************************************/
#pragma once

#ifndef __RENDERABLE_VERTEXS__INCLUDED_H__
#define __RENDERABLE_VERTEXS__INCLUDED_H__

#pragma warning (disable:4005)

#include "MathTypes.h"
#include "Base.h"
#include <D3DX11.h>

class CRenderManager;
class CEffectTechnique;

namespace Vertexs
{

typedef enum VERTEX_TYPOLOGY
{
	POINT_LIST = 0,
	LINE_LIST,
	LINE_STRIP,
	TRIANGLE_LIST,
	TRIANGLE_STRIP,
};

} //namespace Vertexs

class CRenderableVertexs
{
public:
	//-------------------------------------------------
	CRenderableVertexs()
		: m_pVertexBuffer(NULL)
		, m_pIndexBuffer(NULL)
		, m_uVertexCount(0)
		, m_uIndexCount(0)
		, m_Topology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST)
	{
	}

	//-------------------------------------------------
	virtual ~CRenderableVertexs()
	{
		CHECKED_RELEASE(m_pVertexBuffer);
		CHECKED_RELEASE(m_pIndexBuffer);
	}

	//-------------------------------------------------
	virtual void Render(CRenderManager* _pRM, CEffectTechnique* _pTechnique) const = 0;

	//-------------------------------------------------
	virtual void UpdateVertexBuffer(CRenderManager* _pRM, void* _pVertexAddress)
	{
	}

	virtual void UpdateIndexBuffer(CRenderManager* _pRM, void* _pIndexAddress)
	{
	}

	//-------------------------------------------------
	virtual inline uint32	GetVertexCount	() const	{ return m_uVertexCount; }
	virtual inline uint32	GetIndexCount	() const	{ return m_uIndexCount; }
	virtual inline uint32	GetFacesCount	() const	{ return m_uIndexCount / 3; }
	virtual inline uint16	GetVertexType	() const = 0;
	virtual inline uint32	GetVertexSize	() const = 0;
	virtual inline uint32	GetIndexSize	() const = 0;

protected:
	D3D11_PRIMITIVE_TOPOLOGY m_Topology;

	ID3D11Buffer*		m_pVertexBuffer;
	ID3D11Buffer*		m_pIndexBuffer;

	uint32				m_uVertexCount;
	uint32				m_uIndexCount;
};

#endif //__RENDERABLE_VERTEXS__INCLUDED_H__